package com.roocon.thread.chapter02;

import java.util.Arrays;

public class ThreadGroupMain {

  public static void main(String[] args) {
    for (int i = 0; i < 2; i++) {
      new Thread(new Runnable() {
        @Override public void run() {
          //System.out.println();
          try {
            Thread.sleep(2000);
          } catch (InterruptedException e) {
            e.printStackTrace();
          }
        }
      }).start();
    }

    ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();

    Thread[] threads = new Thread[threadGroup.activeCount()];
    threadGroup.enumerate(threads);
    Arrays.asList(threads).forEach(System.out::println);
  }
}
